#include <bits/stdc++.h>

using namespace std;

int m,n,head=1,tail=0,a;
bool hasarised[1005]={0};
int main()
{
    scanf("%d%d",&m,&n);
    int q[1005];
    for(int i=1;i<=n;i++){
        scanf("%d",&a);
        if(!hasarised[a]){
            q[++tail] = a;
            hasarised[a]=1;
        }
        if(tail-head>=m){
                hasarised[q[head]]=0;
                head++;
        }
    }
    cout<<tail;
    return 0;
}
